/*
 * $Id: PlasticBoxStyle.java 110 2009-05-06 11:08:58Z meyer@alphatec.de $
 * 
 *
 * Copyright 2009 DeltaDesk
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package deltadesk.gui.deltagui.widget.box;

import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics2D;
import java.awt.Rectangle;

/**
 * PlasticBoxStyle
 * 
 * Inspired by the panels of DhilshukReddy.
 * 
 * @author Andreas Meyer
 * @version $Revision: 110 $
 */
public class PlasticBoxStyle implements BoxStyle {

	/** The start color of the gradient. */
	private final Color startColor = new Color(40, 150, 255);

	/** The end color of the gradient. */
    private final Color endColor = new Color(74, 165, 255);
    
	/** The rectangle size. */
    private int roundRectSize = 15;


    /**
	 * @see deltadesk.gui.deltagui.graphics.Renderable#render(java.awt.Graphics2D)
	 */
	public void render(final Graphics2D g2) {

		final Rectangle rect = g2.getClipBounds();
        int w = rect.width;
        int h = rect.height;

        g2.setPaint(new GradientPaint(0, 0, startColor, 0, h, endColor, true));
        g2.setPaint(Color.BLACK);
        g2.drawRoundRect(0, 0, w - 1, h - 1, roundRectSize, roundRectSize);
        
        g2.setPaint(new GradientPaint(0, 0, startColor, 0, h - 1, endColor));
        g2.fillRoundRect(1,1, w - 2, h - 2, roundRectSize, roundRectSize);

        g2.setPaint(Color.WHITE);
        g2.fillRoundRect(4,1,w-8,8,20,20);
        
		g2.setPaint(new GradientPaint(0, 0, Color.WHITE, 0, 11, endColor));
		g2.fillRoundRect(4,2,w-8,7,20,20);
		
		g2.setPaint(new GradientPaint(0, 0, Color.WHITE, 0, 10, endColor));
		g2.fillRoundRect(7,9,w-13,h-15,15,15);
    }

}
